package com.blockmeta.bbs.businesslibrary.adapter;

import android.content.Context;
import androidx.annotation.Nullable;
import android.text.TextUtils;
import android.widget.ImageView;

import com.blockmeta.bbs.baselibrary.base.adapter.BaseAdapter;
import com.blockmeta.bbs.businesslibrary.R;
import com.blockmeta.bbs.businesslibrary.pojo.MainTabItemBasePOJO;
import com.chad.library.adapter.base.BaseViewHolder;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by author on 2018/5/10.
 */

public class RankChoiceAdapter extends BaseAdapter<MainTabItemBasePOJO, BaseViewHolder> {
    private Context mContext;

    public RankChoiceAdapter(int layoutResId, @Nullable List<MainTabItemBasePOJO> data, Context context) {
        super(layoutResId, data);
        mContext = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, MainTabItemBasePOJO item) {
        helper.setText(R.id.rankChoiceTv, item.getName());
        if (item.getImg() != null && !TextUtils.isEmpty(item.getImg())) {
            Picasso.with(mContext).load(item.getImg()).into((ImageView) helper.getView(R.id.rankChoiceImg));
        } else {
            helper.setImageResource(R.id.rankChoiceImg, R.drawable.default_header);
        }
    }
}
